package s16;

import net.sf.cglib.reflect.MulticastDelegate;

/**
 * @author wangpp
 */
public class MulticastDelegateTest {

    public static void main(String[] args) {
        MulticastDelegate multicastDelegate = MulticastDelegate.create(IDelegate.class);

        DelegateImpl d1 = new DelegateImpl();
        DelegateImpl d2 = new DelegateImpl();

        multicastDelegate.add(d1);
        multicastDelegate.add(d2);

        System.out.println(multicastDelegate.getTargets());

        IDelegate delegate = (IDelegate) multicastDelegate;

        delegate.setValue("hello delegate");

        System.out.println(d1.getValue());
        System.out.println(d2.getValue());
    }
}
